package xjvm_v1.classfile.cons;


import xjvm_v1.classfile.ConsPoolInfo;
import xjvm_v1.util.TypeTransUtil;
import xjvm_v1.util.U2;

public class ConstantNameandtype extends ConstantBase {
    public U2 nameIndex;
    public U2 descriptorIndex;

    public String getConsInfo(ConsPoolInfo constantPool){
        Integer intIndexOfName = TypeTransUtil.byteArr2Int(nameIndex.u2);
        String fieldName = constantPool.cpInfo[intIndexOfName].getConsInfo(constantPool);

        Integer intIndexOfDescriptor = TypeTransUtil.byteArr2Int(descriptorIndex.u2);
        String descriptor = constantPool.cpInfo[intIndexOfDescriptor].getConsInfo(constantPool);
        return "NameAndType     " + fieldName + ": " + descriptor;
    }


}
